home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
me_cd.zip
/
MEMUTT.DOC
< prev
next >
Wrap
Lisp/Scheme
|
1988-10-11
|
30KB
|
635 lines
========================================================================
== The ME Mutt Connection Craig Durland 8/88 ==
========================================================================
This document describes the link between the Mutt programming langauge
(see MUTT.DOC) and the Mutt Editor (see ME.DOC).
========================================================================
== The ME Mutt functions ==
========================================================================
(append-to-register n [text]) [NUMBER [STRING] : VOID]
Append text or region to register n.
Register 0 is the kill buffer. Registers 1,2,3,4 are general purpose.
For example:
If the region contains "This is a test" then
(clear-register 0)
(append-to-register 0) (append-to-register 0 " foo bar")
will set the kill buffer to "This is is a test foo bar".
Note: appending to a register that contains a rectangle does nothing.
See also: clear-register, copy-rectangle, insert-register, the kill
buffer commmands in ME.DOC.
(arg-flag) [zip : BOOLEAN]
Check to see if somebody set the arg-prefix before calling this
routine (via (universal-argument) or (arg-prefix n)).
See also: arg-prefix.
(arg-prefix [arg]) [[NUMBER] : NUMBER]
Get or set the universal-argument.
With an arg, its the same as ^U before a function.
Notes:
The arg-flag is set to TRUE.
This really sets two prefixes: one for ME commands and one for
Mutt pgms. ME commands and exe-key use and reset the prefix to
1. Pgms can only read the prefix and so it will stay the same
for all children of a pgm unless it is changed by (arg-prefix
n). If it is changed, all the children AND parents will see the
new value. It is a good idea to make a copy of the value upon
entry to a pgm if it is possible that a child will do a
(arg-prefix n).
If prefix is not set, it is always 1 (and the arg-flag is FALSE)
when a pgm or ME command is run from the keyboard.
Note that there is a difference between (arg-prefix 1) and the default.
eg (arg-prefix 1)(delete-char) puts the deleted character into the kill
buffer but (delete-char) does not.
For example, to make META-n start the (universal-argument) count at n,
use the following (where n is 1,2,3,4,5,6,7,8 or 9):
(defun
META-arg { (arg-prefix (- (key-pressed) 0x230))(universal-argument) }
MAIN
{
(int j)
(for (j 1)(< j 10)(+= j 1)
(bind-to-key (concat "META-arg")(concat "M-" j)))
}
)
See also: (arg-flag), (universal-argument) in ME.DOC.
(argc) [zip : NUMBER]
The number of parameters on the command line when ME was invoked +1.
eg "ME foo bar" has argc == 3.
Use argv to look at the parameters.
(argv) [NUMBER : STRING]
The ME command line parameters. There are argc of them, numbering
0...argc-1. (argv 0) is the name of the program (ME) (unless you are
running on MS-DOS 2.x where it is ""), (argv 1) is the first file name
(which is loaded by ME), (argv 2) is the next file name, etc.
For example:
; sequentially load the files specified on the command line
(int nth-file) ; file to load next (a global var initialized to 0)
(defun next-file
{
(if (== 0 nth-file)(nth-file 2)) ; already loaded first file
(if (< nth-file (argc))
{ (visit-file (argv nth-file))(+= nth-file 1) }
(msg "All files read in.")
)
})
(attached-buffer n | name) [NUMBER|STRING : NUMBER]
If given a number, attached-buffer returns the buffer that is attached
to window n. n==-1 means use the current window.
If given a name, attached-buffer returns the buffer that is named
name. Returns -1 if there if the buffer does not exist.
For example:
if the third window is displaying buffer "foobar" and foobar is
the second buffer then:
(attached-buffer -1) and (attached-buffer 2) both return 1.
(attached-buffer "foobar") returns 1.
(attached-buffer "FOOBAR") returns -1.
See also: buffers, windows.
(buffer-created-hook) [zip : zip]
This is called when a buffer is created and allows a pgm to set up
a buffer.
Note: You defun this pgm.
WARNING: This can give ME a headache. Don't do anything fancy (like
switching buffers, inserting, etc). Not even I know for sure what
is safe here.
BUGS: Does not get called on first file on command line.
eg me foo.bar - buffer-created-hook not called on foo.bar but
is called there after (assuming it is defuned in init.mut).
The elsleazo workaround is to put (buffer-created-hook) at the end
of init.mut (ie after the hook has been defuned).
See also: buffer-var, init.mut (an example of how to use
buffer-created-hook to set modes based on file name extension).
(buffer-flags n [x]) [NUMBER [NUMBER] : NUMBER]
Get or set the buffer flags. There are 8 flags represented by the
lower 8 bits of x.
Bit Flag
0x01 Modified. 1 if the buffer has been modified since last save.
0x02 NoCare. Don't care about buffer contents.
0x04 Hidden. Buffer is hidden from user.
The other bits are not used (currently) and may be used by pgms.
Notes:
The Modified flag reports the same info that buffer-modified does.
If you want to mark a buffer as not modified it is better to use
not-modified or buffer-modified because buffer-flags will not
update the modeline if the buffer is being displayed.
The NoCare flag is used whenever ME wants exit or change a buffer -
it is set, ME will not ask before changes are made.
A buffer with the Hidden flag set is invisible to the user -
(next-buffer) skips it, the help and command completion routines
ignore it.
ME only changes the Modified flag.
See also: buffer-modified, buffers.
(buffer-modified n [bool]) [NUMBER [BOOLEAN] : BOOLEAN]
Check to see if buffer n is modified.
If n==-1 the current buffer is used.
(buffer-modified -1) : TRUE if the current buffer is modified.
(buffer-modified 0) : TRUE if the first buffer is modified.
(buffer-modified -1 FALSE) : mark the current buffer as not modified.
(buffer-modified n FALSE) : mark the nth buffer as not modified.
See also: buffer-flags, buffers, current-buffer, (not-modified).
(buffer-name n) [NUMBER : STRING]
Return the name of the nth buffer.
(buffer-name -1) returns the name of the current buffer.
(buffer-name 0) returns the name of the first buffer.
See also: buffers, current-buffer, file-name.
(buffer-stats n array INT 6) [NUMBER BLOB : VOID]
Get some stats on the nth buffer. n==-1 means current buffer.
These stats are: buffer-size (in characters), dot (number of
characters from the start of the buffer), lines (number of text
lines in the buffer), buffer-row (the line in the buffer the dot is
on), wasted (the number of characters allocated but not used) and
character-at-dot (ASCII value - eg if the dot is on a "A" then
character-at-dot==65).
Note that buffer-size may NOT be the same as the file size.
An example of a typical buffer stats routine (ie whats bound to
"^X=") is:
(defun show-buffer-stats ; bind this to "^X="
{
(INT buffer-size dot lines buffer-row wasted char-at-dot ratio)
(buffer-stats -1 (pointer buffer-size))
(ratio 0)(if (!= 0 buffer-size)(ratio (/ (* 100 dot) buffer-size)))
(msg "Row=" buffer-row " (of " lines ")"
" Col=" (current-column) " Y=" (window-row)
" CH=0x" (tobase char-at-dot 16) " .=" dot
" (" ratio "% of " buffer-size "))
})
(buffer-var n [value]) [NUMBER [NUMBER] : NUMBER]
Each buffer has 10 numeric variables (numbered 0,1,...9) associated
with it. These vars are not used by ME - they are there for pgm use.
They live and die with the buffer and are not initialized.
eg (buffer-var 0 123) sets var 0 to 123. (msg (buffer-var 0)) displays
123 in the minibuffer. (x (buffer-var 0)) assigns 123 to x.
(buffer-var 1 (+ (buffer-